<?php
namespace cms\modules\v1\models\express;

use cms\modules\v1\models\Common;
use common\models\Functions;
use yii\base\Exception;

/**
 * This is the model class for table "project_info".
 *
 * @property int $id
 * @property string $name
 */
class ExpressCompany extends Common
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%express_company}}';
    }

    public function getListForSelect() {

        try {
            $where = [];
            $list = static::getByWhere($where, ['*'], '');

            $result = [];
            foreach ($list as $k => $v) {
                $result[] = [
                    'id' => (int) $v['id'],
                    'name' => $v['express_name'],
                ];
            }

            return Functions::formatRestAPI(0, '', $result);
        } catch (Exception $e) {
            return Functions::formatRestAPI(1, $e->getMessage());
        }
    }
}
